package cc.telecomdigital.tdstock.trading.widget;

import java.util.List;

import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class InfoWheelAdapter extends AbstractWheelTextAdapter
{
	/** Info Wheel Adapter for the owner, iItem is the display List on the wheel
	    iCurrent is where to be focus, iTextSize is the size of text  **/
	public InfoWheelAdapter(Context iContext, List<String> iItems,
			int iCurrent, int iTextSize)
	{
		super(iContext);
		this.items = iItems;
		setTextSize(iTextSize);
	}

	@Override
	protected void configureTextView(TextView iTextViewObj)
	{
		super.configureTextView(iTextViewObj);

		iTextViewObj.setTypeface(Typeface.SANS_SERIF);
		iTextViewObj.setTypeface(Typeface.DEFAULT_BOLD);
	}

	@Override
	public View getItem(int index, View iCacheView, ViewGroup iParentGroup)
	{
		return super.getItem(index, iCacheView, iParentGroup);
	}

	private List<String>	items;

	/** Re-initialize the item list on the wheel **/
	public void InitItemList(List<String> iNewItemList)
	{
		items = iNewItemList;
	}

	/** Change the list display on the wheel list **/
	public void ChangeItemList(List<String> iNewItemList)
	{
		items = iNewItemList;
		notifyDataChangedEvent();
	}

	@Override
	public CharSequence getItemText(int index)
	{
		int count;

		count = items.size();
		if (index >= 0 && index < count)
		{
			String item = items.get(index);
			if (item instanceof CharSequence)
				return (CharSequence) item;

			return item.toString();
		}
		return null;
	}

	@Override
	public int getItemsCount()
	{
		return items.size();
	}
}
